import 'package:backend.analytics/domain/entities/amplitude/amplitude_event.dart';
import 'package:backend.analytics/domain/entities/amplitude_api/amplitude_api_event.dart';
import 'package:backend.analytics/domain/helpers/amplitude/create_amplitude_event_type_from_api_one.dart';

abstract class CreateAmplitudeEventFromApiOne {
  AmplitudeEvent call({
    required AmplitudeApiEvent apiEvent,
  });
}

class CreateAmplitudeEventFromApiOneImpl implements CreateAmplitudeEventFromApiOne {
  const CreateAmplitudeEventFromApiOneImpl({
    required CreateAmplitudeEventTypeFromApiOne createAmplitudeEventTypeFromApiOne,
  }) : _createAmplitudeEventTypeFromApiOne = createAmplitudeEventTypeFromApiOne;

  final CreateAmplitudeEventTypeFromApiOne _createAmplitudeEventTypeFromApiOne;

  @override
  AmplitudeEvent call({
    required AmplitudeApiEvent apiEvent,
  }) {
    final eventType = _createAmplitudeEventTypeFromApiOne(
      apiEventType: apiEvent.type,
    );

    return AmplitudeEvent(
      id: apiEvent.id,
      time: apiEvent.time,
      type: eventType,
      purchaseItemSku: apiEvent.purchaseItemSku,
      userId: apiEvent.userId,
      deviceId: apiEvent.deviceId,
      revenue: apiEvent.revenue,
    );
  }
}
